Skip to content

Fix unnecessary update of ra-input-rich-text on edit - #3099

Merged
djhi merged 7 commits into
marmelab:masterfrom
roychoo:fix-ra-input-rich-text
Apr 19, 2019
Merged

djhi merged 7 commits into
marmelab:masterfrom
roychoo:fix-ra-input-rich-text

Conversation

@roychoo

@roychoo roychoo commented Apr 5, 2019 •

Copy link
Copy Markdown

Hi,

in ra-input-rich-text,

whenever the text changes, below is the sequence of events happening.
Original text <p>test</p>

  1. User change text to <p>test1</p>
  2. onTextChange fired
  3. componentDidUpdate fired
  4. update happens as previous prop value is still <p>test</p>, but unecessary
  5. onTextChange fired again.
  6. stops there as the prevProp input value is the same as current prop input value

2nd issue is that, it seems quilljs is always adding additional <p> after this method

this.quill.setContents(
     this.quill.clipboard.convert(this.props.input.value)
)

ONLY for the text that has special characters, i.e ARTÍCULO 1.- El presente reglamento es de observancia obligatoria after you bold ARTÍCULO 1

fixes #3073

@djhi djhi added this to the 2.8.5 milestone Apr 5, 2019
@djhi

djhi commented Apr 5, 2019

Copy link
Copy Markdown
Contributor

Thanks! It seems the tests are failing though

@roychoo
roychoo force-pushed the fix-ra-input-rich-text branch from b38e3ca to 661b8a1 Compare April 11, 2019 02:19
@roychoo

roychoo commented Apr 13, 2019

Copy link
Copy Markdown
Author

Hi just want to check, did anyone take the opportunity to review the code?

@djhi djhi left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll wait for another core team member to review before merging though

Comment thread test-setup.js
Comment thread packages/ra-input-rich-text/src/index.spec.js Outdated
Comment thread packages/ra-input-rich-text/src/index.spec.js
});

it('should call text-change event only once when editing', async () => {
const mockFn = jest.fn();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call it handleChange

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure ? I still see mockFn

@roychoo roychoo Apr 19, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry I misunderstood, I thought you meant the test description. Will make the required change in another 3 hours.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djhi done.

Comment thread packages/ra-input-rich-text/src/index.spec.js
Comment thread packages/ra-input-rich-text/src/index.spec.js Outdated
Roy Choo added 4 commits April 16, 2019 16:03
quill require mock on some DOM apis while in test.
1. add reason for shim
2. add reason for using jest fake timers
@djhi
djhi requested a review from fzaninotto April 19, 2019 12:04
});

it('should call text-change event only once when editing', async () => {
const mockFn = jest.fn();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure ? I still see mockFn

@djhi djhi modified the milestones: 2.8.5, 2.8.6 Apr 19, 2019
@djhi
djhi merged commit 8b2cbc2 into marmelab:master Apr 19, 2019
@djhi

djhi commented Apr 19, 2019

Copy link
Copy Markdown
Contributor

Thanks!

@roychoo

roychoo commented Apr 19, 2019

Copy link
Copy Markdown
Author

Thanks for the review and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ra-input-rich-text breaks when using special characters

3 participants